import request from '../../utils/Request'
import PageUtils from '../../utils/PageUtils'

export const saveProduct = data => {
  return request({
    method: 'post',
    url: '/api/monitor/product/save',
    data: data
  })
}

export const createProduct = (data, idempotentCode) => {
  return request({
    method: 'post',
    url: '/api/monitor/product/create',
    data: data,
    headers: {
      common: {
        idempotent: idempotentCode
      }
    }
  })
}

export const updateProduct = data => {
  return request({
    method: 'post',
    url: '/api/monitor/product/update',
    data: data
  })
}

export const updateProductStatus = (productId, status) => {
  return request({
    method: 'get',
    url: '/api/monitor/product/' + productId + '/status/' + status,
    params: {}
  })
}

export const deleteProduct = bId => {
  return request({
    method: 'get',
    url: '/api/monitor/product/delete/' + bId,
    params: {}
  })
}

export const listProduct = (data, current, size) => {
  let pageUrl = PageUtils.page(current, size)
  return request({
    method: 'get',
    url: '/api/monitor/product/list?' + pageUrl,
    params: data
  })
}

export const selectProduct = bId => {
  return request({
    method: 'get',
    url: '/api/monitor/product/select/' + bId,
    params: {}
  })
}